package org.zjt.rpc.util;

import org.zjt.rpc.service.RPCFacade;
import org.zjt.rpc.service.RpcImpl;

import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by zhangjuntao on 2017/4/12.
 */
public class BeanRelationTree {
    private static ConcurrentHashMap<String,String> ioc = new ConcurrentHashMap<>();
    public static void registerBean(){
        RPCFacade rpcFacade = new RpcImpl();
        if (rpcFacade.getClass().getInterfaces() == null  || rpcFacade.getClass().getInterfaces().length ==0)
            return;
        for (Class v1: rpcFacade.getClass().getInterfaces())
            ioc.put(v1.getName(),rpcFacade.getClass().getName());
    }

    public static String getBeanImple(String className){
        if (ioc.isEmpty())
            registerBean();
        return  ioc.get(className);
    }
}
